package com.wntms.zjy.dao;

import com.wntms.zjy.pojo.CustomerComplain;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author xzbz
 * @create 2022-11-22 22:35
 */
@Mapper
public interface CustomerComplainDao {
    //忽略投诉：直接删除
    @Delete("delete from customer_complain where id = #{id}")
    public int deleteComplain(Integer id);

    //用户添加投诉
    @Insert("insert into customer_complain values(null,#{fid},#{fsid},#{complain_content},#{complain_time},#{complaint},false)")
    public int addComplain(CustomerComplain customerComplain);
    //处理投诉:回复
    @Update("update customer_complain set iswether = #{iswether}," +
            "reply_content = #{replyContent},reply_time = #{replyTime},respondent = #{respondent} where id = #{id}")
    public int replyComplain(CustomerComplain customerComplain);
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "complainContent",column = "complain_content"),
            @Result(property = "complainTime",column = "complain_time"),
            @Result(property = "complaint",column = "complaint"),
            @Result(property = "iswether",column = "iswether"),
            @Result(property = "replyContent",column = "reply_content"),
            @Result(property = "replyTime",column = "reply_time"),
            @Result(property = "respondent",column = "respondent"),
            @Result(property = "fid",column = "fid"),
            @Result(property = "freightContract",column = "fid",one = @One(select = "com.wntms.zjy.dao.FreightContractDaoz.findById"))
    })
    @Select("select * from customer_complain")
    public List<CustomerComplain> findAll();


    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "complainContent",column = "complain_content"),
            @Result(property = "complainTime",column = "complain_time"),
            @Result(property = "complaint",column = "complaint"),
            @Result(property = "iswether",column = "iswether"),
            @Result(property = "replyContent",column = "reply_content"),
            @Result(property = "replyTime",column = "reply_time"),
            @Result(property = "respondent",column = "respondent"),
            @Result(property = "fid",column = "fid"),
            @Result(property = "freightContract",column = "fid",one = @One(select = "com.wntms.zjy.dao.FreightContractDaoz.findById"))
    })
    @Select("select * from customer_complain where fid = #{fid}")
    public CustomerComplain findByFid(String fid);
}
